CSS/HTML

推荐列表 站点导航

当前位置:首页 > 脚本编程 > CSS/HTML >

HTML5如何在手机端调用相机?

来源:网络整理  作者:  发布时间:2020-12-17 19:08
这篇文章主要介绍了Html5在手机端调用相机的方法实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具...
当accept=”audio”时,只要有capture就调用设备麦克风,忽略user和environment值。
5. 当input没有capture时,根据accppt类型给出文件夹选项以及摄像头或者录音机选项
7. 无multiple时都只能单文件

input调用设备录像
var ua = navigator.userAgent.toLowerCase(); if(ua.match(/android/i)) == "android") { alert("android"); } if(ua.match(/iPhone/i)) == "iPhone") { alert("iPhone"); } if(ua.match(/iPad/i)) == "iPad") { alert("iPad"); }<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <input type="file" accept="image/*" capture="camera"> <input type="file" accept="video/*" capture="camcorder"> <input type="file" accept="audio/*" capture="microphone"> </body> </html> <script> var file = document.querySelector('input'); if (getIos()) { file.removeAttribute("capture"); //如果是ios设备就删除"capture"属性 } function getIos() { var ua=navigator.userAgent.toLowerCase(); if (ua.match(/iPhone\sOS/i) == "iphone os") { return true; } else { return false; } } </script>

推荐教程:《HTML教程

以上就是HTML5如何在手机端调用相机?的详细内容,更多请关注聚合云库其它相关文章!

HTML5官方文档解释:capture属性用于调用设备的摄像头或麦克风。
官方文档:

至于网上提到的camera和filesystem,官方没提。
6. input含有multiple时访问文件夹可勾选多文件,调用系统摄像头或者录音机都只是单文件
3. 当accept=”image/,video/”,capture=”user”调用前置摄像头,capture=”其他值”,调用后置摄像头,默认照相,可切换录像

iOS最遵守遵守HTML5规范,其次是X5内核,安卓的webview基本忽略了capture。
理想情况下应该按照如下开发webview:

2. 当accept=”video/”时,capture=”user”调用前置录像机,capture=”其他值”,调用后置录像机

判断设备类型

4. 当accept=”audio/*”时,capture=”放空或者任意值”,调用录音机

1.当accept=”image/”时,capture=”user”调用前置照相机,capture=”其他值”,调用后置照相机
当accept=”audio/或video/”时capture只有两种值,一种是user,用于调用面向人脸的摄像头(例如手机前置摄像头),一种是environment,用于调用环境摄像头(例如手机后置摄像头)。

HTML5如何在手机端调用相机?

相关热词: HTML 调用 HTML5

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://v30.fanwenzhu.com/jiaob/cssm/4917.shtml

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

HTML5如何在手机端调用相机?

2020-12-17 编辑:

当accept=”audio”时,只要有capture就调用设备麦克风,忽略user和environment值。
5. 当input没有capture时,根据accppt类型给出文件夹选项以及摄像头或者录音机选项
7. 无multiple时都只能单文件

input调用设备录像
var ua = navigator.userAgent.toLowerCase(); if(ua.match(/android/i)) == "android") { alert("android"); } if(ua.match(/iPhone/i)) == "iPhone") { alert("iPhone"); } if(ua.match(/iPad/i)) == "iPad") { alert("iPad"); }<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <input type="file" accept="image/*" capture="camera"> <input type="file" accept="video/*" capture="camcorder"> <input type="file" accept="audio/*" capture="microphone"> </body> </html> <script> var file = document.querySelector('input'); if (getIos()) { file.removeAttribute("capture"); //如果是ios设备就删除"capture"属性 } function getIos() { var ua=navigator.userAgent.toLowerCase(); if (ua.match(/iPhone\sOS/i) == "iphone os") { return true; } else { return false; } } </script>

推荐教程:《HTML教程

以上就是HTML5如何在手机端调用相机?的详细内容,更多请关注聚合云库其它相关文章!

HTML5官方文档解释:capture属性用于调用设备的摄像头或麦克风。
官方文档:

至于网上提到的camera和filesystem,官方没提。
6. input含有multiple时访问文件夹可勾选多文件,调用系统摄像头或者录音机都只是单文件
3. 当accept=”image/,video/”,capture=”user”调用前置摄像头,capture=”其他值”,调用后置摄像头,默认照相,可切换录像

iOS最遵守遵守HTML5规范,其次是X5内核,安卓的webview基本忽略了capture。
理想情况下应该按照如下开发webview:

2. 当accept=”video/”时,capture=”user”调用前置录像机,capture=”其他值”,调用后置录像机

判断设备类型

4. 当accept=”audio/*”时,capture=”放空或者任意值”,调用录音机

1.当accept=”image/”时,capture=”user”调用前置照相机,capture=”其他值”,调用后置照相机
当accept=”audio/或video/”时capture只有两种值,一种是user,用于调用面向人脸的摄像头(例如手机前置摄像头),一种是environment,用于调用环境摄像头(例如手机后置摄像头)。

HTML5如何在手机端调用相机?

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://v30.fanwenzhu.com/jiaob/cssm/4917.shtml

相关文章

风云图片

推荐阅读

返回CSS/HTML频道首页